package com.zp.ojcodesandbox;

import cn.hutool.core.io.resource.ResourceUtil;
import com.zp.ojcodesandbox.model.ExecuteCodeRequest;
import com.zp.ojcodesandbox.model.ExecuteCodeSandResponse;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

@Component
public class JavaNativeCodeSandBox extends CodeSandeBoxTemplate implements CodeSandBox {
    public static void main(String[] args){
        JavaNativeCodeSandBox javaNativeCodeSandBox = new JavaNativeCodeSandBox();
        ExecuteCodeRequest executeCodeRequest = new ExecuteCodeRequest();
        executeCodeRequest.setInputs(Arrays.asList("1 2", "3 4"));
        String code = ResourceUtil.readStr("testCode/Main.java", StandardCharsets.UTF_8);
        executeCodeRequest.setCode(code);
        executeCodeRequest.setLanguage("java");
        ExecuteCodeSandResponse executeCodeSandResponse = javaNativeCodeSandBox.executeCode(executeCodeRequest);
        System.out.println(executeCodeSandResponse);
    }
    @Override
    public ExecuteCodeSandResponse executeCode(ExecuteCodeRequest executeCodeRequest){
        return super.executeCode(executeCodeRequest);
    }
}
